package leetcode.code172;

public class Solution implements ISolution {

	public static void main(String[] args) {
		Solution so = new Solution();
		for (int i = 1; i < 26; i++) {
			int num = so.trailingZeroes(i);
			if (num != 0)
				System.out.println(i + " 的阶乘结果有: " + num);
		}
	}

	@Override
	public int trailingZeroes(int n) {
		if (n < 5) {
			return 0;
		}
		if (n == 5)
			return 1;
		int count5 = 1;
		for (int i = 6; i <= n; i++) {
			int num = i;
			while (num != 0) {
				int mod = num % 5;
				if (mod == 0) {
					count5++;
				}else {
					break;
				}
				num = num / 5;
			}
		}
		return count5;
	}

}
